Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.

London 9 -Marziyeh Azhdari - JS-Core-1 - Week 1 #429

Open
MariAzhdari wants to merge 4 commits into
CodeYourFuture:masterfrom
MariAzhdari:master
Open

London 9 -Marziyeh Azhdari - JS-Core-1 - Week 1 #429
MariAzhdari wants to merge 4 commits into
CodeYourFuture:masterfrom
MariAzhdari:master

Conversation

@MariAzhdari
Copy link
Copy Markdown

Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in HOW_TO_MARK.md in the root of this repository

Your Details

  • Your Name: Marziyeh Azhdari
  • Your City:London
  • Your Slack Name:MariAzh

Homework Details

  • Module:JS
  • Week:1

Notes

  • What did you find easy?

  • What did you find hard?

  • What do you still not understand?

  • Any other notes?

Copy link
Copy Markdown

@Gayle-Thompson-Igwebike Gayle-Thompson-Igwebike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job Marziyeh. Well done.


let first="Hello, my name is "
let myName="Mari"
let message=first+myName
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how you concatenated the first+myName in the variable. I did it the very long way.... This is good.

@@ -1,5 +1,7 @@
// Write your function here
function greeting(name){
console.log("Hello,my name is ;"+(name));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Marziyeh, Just looking at this code and I thought, I would have written it like this:
console.log("Hello, my name is " + name);

What do you think?

Copy link
Copy Markdown
Author

@MariAzhdari MariAzhdari Nov 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly.Thanks, Gayle.


function convertToUSD() {}
function convertToUSD(price) {
return price*1.4
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this syntax...mine was sooo long... Great job.

@@ -1 +1,6 @@
console.log("Hello world");
console.log("cd exercises/B-hello-world")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting test! I hope you realised that this will still just print "cd exercises/B-hello-world", even if this command has a very different meaning when you run it in the console, that is, this will not change directory when run inside the console.log as a string.

let myName="mari"
let lengthName=myName.length
// let messageTwo=`my name is${myName}and my name is${lengthName}characters long`
let message=" My name is"+myName+" and my name is " + lengthName+" characters long"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very small comment, but you should try to be consistent with your style. If you are putting spaces before and after the plus signs, for example. is" + myName + " an you should do that for all strings concatenations.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the .trim method to remove the extra whitespace for this I made space. so I should do that for all strings concatenations??

Copy link
Copy Markdown

@Gayle-Thompson-Igwebike Gayle-Thompson-Igwebike Dec 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mcarballopacheco Your suggestion is quite right. I'm practising consistency also. Javascript is soo hard for me

let total=numberOfMentors+numberOfStudents
let percentageOfStudent=numberOfStudents/total*100;
console.log("Percentage students: "+Math.round(percentageOfStudent)+"%");
let PercentageMentors=100-percentageOfStudent
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could have also calculated the percentage of mentors, as.
let PercentageMentors=numberOfMentors/total*100;
and then use round. Surprisingly, this may not always be the same as the way you calculated it, because if the fraction ends in 0.5, it will always go up to the next integer when using Math.round. This is why in general, it is important to be aware and careful when rounding up numbers.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got it thanks.

@@ -1,5 +1,7 @@
// Write your function here
function greeting(name){
console.log("Hello,my name is ;"+ name);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here it would have make more sense based on the exercise to return the greeting and then use console.log() outside of the function.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function greeting(name){
return name;
}
console.log("Hello,my name is ;"+greeting("Daniel"));

Is it ok?

// Call the function and assign to a variable `sum`

console.log(sum);
console.log(sum(13,124));
Copy link
Copy Markdown

@mcarballopacheco mcarballopacheco Dec 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will work, but in the exercise it mentioned to assign the value to a variable called sum, so:
let sum = add(13, 124)
console.log(sum)

function result(name){
return console.log(greeting(name));
}
result(mentor1);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

Comment thread extra/2-piping.js
// Why can this code be seen as bad practice? Comment your answer.
//there are three functions that are not necessary and I think it is possible with a shorter code as well.(I am not sure!!!!!!!!!!!!!!!!!)
let badCode =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is in general a bad idea to call many functions in the same line. It makes the code very hard to read. A better idea is to call each function once in a line and assign the result to a variable which then gets called in the following like but the next function, etc.

@@ -1,17 +1,24 @@
// Add comments to explain what this function does. You're meant to use Google!
//The Math.random() function returns a floating-point, pseudo-random number that's greater than or equal to 0 and less than 1,
function getRandomNumber() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here, the question is asking what does the getRandomNumber() does also?

Comment thread mandatory/4-tax.js

function addTaxAndFormatCurrency() {}
function addTaxAndFormatCurrency(price) {
return `£${(price * 1.2).toFixed(2)}`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should have used the calculateSalesTax function that you just created. The reason we create functions is to not repeat code which minimises errors. For example, let say the sales tax changes from 20% to 25%. if all of the times you calculated the sales tax you always use the calculateSalesTax function, then you only need to change the calculation in one place only. But if you are calculating in different places, then you would have to find them one by one.

Copy link
Copy Markdown

@mcarballopacheco mcarballopacheco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work Mari!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants